/**
 *******************************************************************************
 * @FileName  : led.c
 * @Author    : GaoQiu
 * @CreateDate: 2021-4-27
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */

#include "platform/platform.h"
#include "board/board.h"


/**
 * @brief  : Initializate All LED.
 * @param  : none.
 * @param  : none.
 */
void BSP_InitAllLed(void)
{
#ifdef TLSR8258_DK48
	uint16_t ledPin[] = {
		LED_BLUE_PIN, LED_GREEN_PIN, LED_WHITE_PIN, LED_RED_PIN
	};
#elif defined(TLSR8258_DG48)
	uint16_t ledPin[] ={
		LED_BLUE_PIN, LED_GREEN_PIN, LED_WHITE_PIN, LED_RED_PIN, LED_YELLOW_PIN,
	};
#endif

	for(int i=0; i<COUNTOF(ledPin); i++){
		GPIO_InitEx(ledPin[i], GPIO_Mode_Out);
		GPIO_WriteBitsEx(ledPin[i], !LED_VALID_LEVEL);
	}
}

/**
 * @brief  : Initializate LED.
 * @param  : ledPin     LED Pin.
 * @param  : none.
 */
void BSP_InitLed(uint16_t ledPin)
{
	GPIO_InitEx(ledPin, GPIO_Mode_Out);
	GPIO_WriteBitsEx(ledPin, !LED_VALID_LEVEL);
}

/**
 * @brief  : Open LED.
 * @param  : ledPin     LED Pin.
 * @param  : none.
 */
void BSP_LedOn(uint16_t ledPin)
{
	GPIO_WriteBitsEx(ledPin, LED_VALID_LEVEL);
}

/**
 * @brief  : Close LED.
 * @param  : ledPin     LED Pin.
 * @param  : none.
 */
void BSP_LedOff(uint16_t ledPin)
{
	GPIO_WriteBitsEx(ledPin,!LED_VALID_LEVEL);
}

/**
 * @brief  : Toggle LED.
 * @param  : ledPin     LED Pin.
 * @param  : none.
 */
void BSP_LedToggle(uint16_t ledpin)
{
	GPIO_ToggleBitsEx(ledpin);
}


